#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

struct node {
	ll to;
	ll nxt;
} e[3000100];

ll n, m, tot, ans;
ll head[1500100];
ll p[1500100];
ll dis[30][30];
ll dep[1500100];
ll d[1500100];
bool sub;
bool b[210];

inline void add(ll u, ll v) {
	tot++;
	e[tot].to = v;
	e[tot].nxt = head[u];
	head[u] = tot;
	return;
}

void dfs(ll u, ll fa) {
	p[u] = fa;
	dep[u] = dep[fa] + 1;
	for (ll i = head[u]; i != 0; i = e[i].nxt) {
		ll v = e[i].to;
		if (v == fa) {
			continue;
		}
		dfs(v, u);
	}
	return;
}

int main() {
	freopen("life.in", "r", stdin);
	freopen("life.out", "w", stdout);
	scanf("%lld%lld", &n, &m);
	for (ll i = 1; i < n; i++) {
		ll u, v;
		scanf("%lld%lld", &u, &v);
		add(u, v);
		add(v, u);
		d[u]++;
		d[v]++;
	}
	sub = 1;
	for (ll i = 1; i <= n; i++) {
		if (d[i] > 2) {
			sub = 0;
		}
	}
	if (sub) {
		printf("YES\n");
		printf("%lld\n", m);
		return 0;
	}
	if (n <= 18) {
		dfs(1, 0);
		for (ll i = 1; i <= n; i++) {
			for (ll j = 1; j <= n; j++) {
				ll u = i;
				ll v = j;
				dis[i][j] = (1 << (i - 1)) | (1 << (j - 1));
				while (u != v) {
					if (dep[u] < dep[v]) {
						swap(u, v);
					}
					u = p[u];
					dis[i][j] |= (1 << (u - 1));
				}
			}
		}
		for (ll i = 0; i < (1 << n); i++) {
			bool ok = 1;
			for (ll j = 1; ok && j <= n; j++) {
				for (ll k = 1; ok && k <= n; k++) {
					if (__builtin_popcount(dis[j][k]) == m) {
						ll x = (i & dis[j][k]);
						if (__builtin_popcount(x) != 1) {
							ok = 0;
							break;
						}
					}
				}
			}
			ans += ok;
		}
		if (!ans) {
			printf("NO\n");
			printf("0\n");
		} else {
			printf("YES\n");
			printf("%lld\n", ans);
		}
	} else {
		printf("NO\n");
		printf("0\n");
	}
	return 0;
}
